const express = require("express");
const router = express.Router(); // 创建服务器的实例对象

const worker_handler = require("../router_handler/worker"); // 导入处理函数模块

const expressJoi = require("@escook/express-joi"); // 导入验证数据的中间件
const {
  worker_reg_schema,
  worker_login_schema,
  worker_update_pwd_schema,
  worker_alterData_schema,
} = require("../schema/worker"); // 导入验证规则对象

router.post(
  "/workerRegworker",
  expressJoi(worker_reg_schema),
  worker_handler.regworker
); // 注册

router.post(
  "/workerLogin",
  expressJoi(worker_login_schema),
  worker_handler.workerLogin
); // 登录

router.post("/workerLogout", worker_handler.workerLogout); // 注销

router.post(
  "/workerUpdatedPwd",
  expressJoi(worker_update_pwd_schema),
  worker_handler.workerUpdatePassword
); // 重置密码

router.post(
  "/alterData",
  expressJoi(worker_alterData_schema),
  worker_handler.alterData
);

module.exports = router;
